//app.js
import { databaseAdd } from "./util/database.js"
import { cloud_login } from "./util/cloud.js"
App({
  onLaunch: function () {
    
    if (!wx.cloud) {
      console.error('请使用 2.2.3 或以上的基础库以使用云能力')
    } else {
      //小程序端云函数初始化
    }
    cloud_login("", (res) => {
      console.log(res);
      if (!!res.result.openid) {
        wx.setStorageSync("openid", res.result.openid)
      }
    })
    this.globalData = {}
  },
  //页面跳转
  routerTo(method, url, success, faild) {
    if (method == "navigateTo") { //保存当前页面跳转
      wx.navigateTo({
        url: url,
        success: success,
        faild: faild
      });
    } else if (method == "redirectTo") { //关闭当前页面跳转
      wx.redirectTo({
        url: url,
        success: success,
        faild: faild
      });
    } else if (method == "reLaunch") { //关闭所有页面跳转
      wx.reLaunch({
        url: url,
        success: success,
        faild: faild
      });
    } else if (method == "switchTab") { //跳转到tabbar
      wx.switchTab({
        url: url,
        success: success,
        faild: faild
      });
    } else {

    }
  },
  inLogin(){
    wx.checkSession((res)=>{
      console.log(res);
    },(res)=>{
      console.log(res);
    })
  }
})
